<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /* 
    需求：
        小明家里有三个人，爸爸和妈妈，小明是男的，今年18岁
        兴趣爱好是打篮球和读书，爸爸是软件程序员，妈妈是UI设计师，
        小明家在深圳南山有一套100平方的房子，户型是三房一厅，
        今年小明家刚买了一辆特斯拉Model3.

        使用 **对象字面量**、**new Object** 、**构造函数** 三种方式创建以上对象
     */

     //创建  new Object 方法
        let xiaoming = new Object();
        xiaoming.name="小明";
        xiaoming.age = 18;
        xiaoming.sex = "男";
        xiaoming.hobby = "打篮球和读书";
        console.log(xiaoming);

        let baba = new Object();
        baba.work = "软件程序员";
        console.log(baba);

        let mama = new Object();
        mama.Obj = "UI设计师";
        console.log(mama);

        let family = new Object();
        family.address = "深圳南山";
        family.type = "三房一厅";
        family.size = "100平方";
        console.log(family);


        // 对象字变量方法
        xiaohong = {              //变量？
            name: "xiaohong",
            age: 20,
            sex: "女",
            hobby: "美图秀秀和ps",
        }
        console.log(xiaohong);

        ba = {
            work: "软件程序员"
        }
        console.log(ba);

        let ma = {
            work: "UI设计师"
        }
        console.log(ma);

        let house = {
            address: "深圳南山",
            type: "三房一厅",
            size: "100平方"

        }
        console.log(house);


        //构造函数对象方法
        function Xiaohua(a, b, c) {
            this.age = a;
            this.sex = b;
            this.interest = c;
        }
        //Xiaohua(18,"女","健身与音乐");
        let Xiaohua1 = new Xiaohua(18, "女", "健身与音乐");
        console.log(Xiaohua1);
        console.log(typeof Xiaohua1);

        function Daming(age, sex, hobby) {
            this.age = age;
            this.sex = sex;
            this.interest = hobby;
        }
        let Daming1 = new Daming(20, "男", "打篮球和读书");
        console.log(Daming1);

         xiaoming.whole = function(){
            console.log("我的名字叫",this.name,"我爸爸是做",baba.work,"我妈妈的工作是",mama.Obj);
        }
        xiaoming.whole();
</script>
</html>